package com.hzqy.service.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.statistics.ContentUploadDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.StatDataContentUploadVo;

@Service
public class ContentUploadServiceBean extends GenericServiceBean<PmsUserVo, ContentUploadDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private ContentUploadDao contentUploadDao;
	
	@Override
	public ContentUploadDao getEntityDao() {
		return contentUploadDao;
	}
	

	public Map<String, Object> selectContentUploadList(StatDataContentUploadVo statDataContentUploadVo, int curPage, int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = contentUploadDao.selectContentUploadCount(statDataContentUploadVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_sdcu_type", statDataContentUploadVo.getF_sdcu_type());
			map.put("f_sdcu_platform", statDataContentUploadVo.getF_sdcu_platform());
			map.put("beginDate", statDataContentUploadVo.getBeginDate());
			map.put("endDate", statDataContentUploadVo.getEndDate());
			map.put("monthDate", statDataContentUploadVo.getMonthDate());
			map.put("weekDate", statDataContentUploadVo.getWeekDate());
			List<StatDataContentUploadVo> results = contentUploadDao.selectContentUploadList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataContentUploadVo>());
		}
		return map;
	}
	
	public Map<String,Object> selectExcelList(StatDataContentUploadVo statDataContentUploadVo) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = contentUploadDao.selectContentUploadCount(statDataContentUploadVo);
		map.put("total", rowCount);
		if(rowCount > 0) {
			map.put("f_sdcu_type", statDataContentUploadVo.getF_sdcu_type());
			map.put("f_sdcu_platform", statDataContentUploadVo.getF_sdcu_platform());
			map.put("beginDate", statDataContentUploadVo.getBeginDate());
			map.put("endDate", statDataContentUploadVo.getEndDate());
			map.put("monthDate", statDataContentUploadVo.getMonthDate());
			map.put("weekDate", statDataContentUploadVo.getWeekDate());
			List<StatDataContentUploadVo> results = contentUploadDao.selectContentUploadExcelList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataContentUploadVo>());
		}
		return map;
	}
	
}
